@extends('layouts.admin')
      @section('xgshopym')
      <li><a href="{{URL('admin/shopym')}}"> 编辑商品</a></li>
      <li><a href="{{URL('admin/shopym/add')}}"> 增加商品</a></li>
      @endsection
      @section('xgleibie')
      <li><a href="{{url('admin/leibie')}}" >编辑类别</a></li>
      <li><a href="{{url('admin/leibie/add')}}" > 增加类别</a></li>
      @endsection
      @section('xgvip')
      <li><a href="{{url('admin/user')}}"><i class="fa fa-user"></i><span>会员管理</span></a></li>
      @endsection
      @section('xgdingdan')
      <li><a href="{{url('admin/dingdan')}}"><i class="fa fa-cube"></i><span>编辑订单</span></a></li>
      @endsection
      @section('bjgonggao')
      <li><a href="{{URL('admin/gonggao')}}" class="active"> 编辑公告</a></li>
      <li><a href="{{URL('admin/gonggao/add')}}"> 增加公告</a></li>
      @endsection
      @section('page-wrapper')
        <div class="content">
            <div class="row">
                <div class="col-sm-4 col-3">
                    <h4 class="page-title">公告管理</h4>
                </div>
                <div class="col-sm-8 col-9 text-right m-b-20">
                    <a href="{{url('admin/gonggao/add')}}" class="btn btn btn-primary btn-rounded float-right"><i class="fa fa-plus"></i> 添加公告</a>
                    <!-- <a class="btn btn-primary btn-rounded " href="#" data-toggle="modal" data-target="#exit_patient"> 修改</a> -->
                </div>
            </div>

           
            <div class="row">
              <div class="col-md-12">
                <div class="table-responsive">
                  <table class="table table-border table-striped custom-table mb-0">
                     <form action="{{url('admin/gonggao/delall')}}" method="post" >
                    <thead>
                      <tr>
                        <th>复选</th>
                       
                        <th>公告主题</th>
                        <th class="text-center">操作</th>
                      </tr>
                    </thead>
                    <tbody>
                    @foreach($result as $value)
                      <tr>
                        <td><input type="checkbox" name="checked[]" style="zoom:140%;"  value="{{$value->id}}"/></td>
                       
                        <td >{{$value->title}}</td>
                        <td class="text-center">
                            <a class="btn btn-primary" href="{{URL('admin/gonggao/exit',$value->id)}}"> 修改</a>
                            <a class="btn btn-danger delbtn" href="{{URL('admin/gonggao/del',$value->id)}}" style="color: #fff;background-color: #f62d51;"> 删除</a>
                        </td>		
                      </tr>
                    @endforeach	

                    {{csrf_field()}} 
                      <tr style="width: 100%;">                   
                        <td><input type="submit" value="删除选择项" class="btn btn-danger float-left"  ></td>
                        <td style="display: inline-block; margin-left: -5%;margin-top: 15px;border-style: none ;">{{$result->links()}}</td> 
                      </tr>
                    </tbody>
                     </form> 
                  </table>
                </div>
              </div>
            </div>
          
        </div>


   
  <!-- 引入 layui.css -->
  <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
  <script src="{{URL::asset('root\js/jquery-3.2.1.min.js')}}"></script>
  <!-- 引入 layui.js -->
  <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>

    <script>
        // 生成一个token crsf
        const _token = "{{csrf_token()}}";

        // 给删除按钮绑定事件
        $('.delbtn').click(function(evt){
            // 得到请求的URL地址
            let url = $(this).attr('href');
            // 发起一个delete请求
            $.ajax({
                url,
                data:{_token},
                type:'DELETE',
                dataType:'json'
            }).then(({status,msg})=>{
                if(status == 0){
                    // 提示插件
                    layer.msg(msg, {time: 2000,icon: 1},()=>{
                        $(this).parents('tr').remove();
                    });
                }
            });

            // jQuery取消默认事件
            return false;
            
        });
    </script>

 @endsection
